package com.xuecheng.learning.controller;

import com.xuecheng.base.result.RestResponse;
import com.xuecheng.learning.service.IOpenLearningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 勾新杰
 * @version 1.0
 * @description:
 * @date 2025/3/11 17:22
 */
@RestController
@RequestMapping("/open/learn")
@RequiredArgsConstructor
@Api(tags = "公开学习接口")
public class OpenLearningController {

    private final IOpenLearningService learningService;

    /**
     * 获取视频
     *
     * @param courseId    课程id
     * @param teachplanId 课程计划id
     * @param mediaId     视频id
     * @return 视频
     */
    @ApiOperation("获取视频")
    @GetMapping("/getvideo/{courseId}/{teachplanId}/{mediaId}")
    public RestResponse<String> getVideo(@PathVariable("courseId") Long courseId, @PathVariable("teachplanId") Long teachplanId, @PathVariable("mediaId") String mediaId) {
        String url = learningService.getVideo(courseId, teachplanId, mediaId);
        return RestResponse.success(url);
    }
}
